package aes.server;

import java.sql.*;

/**
 * This class represents manager used in order to interact with the DataBase
 *
 * @see This class implements singletone design pattern
 */
public class DBManager {
	
	private static DBManager manager=null;
	private static Connection conn=null;
	
	/**
	 * Constructor
	 */
	private DBManager(){
		try {
			Class.forName("com.mysql.jdbc.Driver").newInstance();
		} catch (Exception e) {
			
			e.printStackTrace();
			return;
		} 
		try {
			conn = DriverManager.getConnection("jdbc:mysql://localhost/aes","root","1234");
		} catch (SQLException e) {
			
			e.printStackTrace();
			return;
		}
		
	}
	 
	/**
	 * Get instance of DBManager
	 * @return
	 */
	public static DBManager getInstance(){
		if (manager==null)
			manager=new DBManager();
		return manager;
	}

	public  Connection getConnection(){
		return conn;
	}
}
